package com.excellence.service.impl;

import com.excellence.mapper.WarningMapper;
import com.excellence.pojo.Warning;
import com.excellence.service.WarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName WarningServiceImpl
 * @Description TODO
 * @date 2024/4/8 10:51
 * @Version 1.0
 */
@Service
public class WarningServiceImpl implements WarningService {
    @Autowired
    WarningMapper warningMapper;

    @Override
    public int deleteByKey(Long id) {
        Warning record = warningMapper.selectByPrimaryKey(id);
        record.setDeleted(1);
        return warningMapper.updateByPrimaryKey(record);
    }
    @Override
    public int deleteByPrimaryKey(Long id) {
        return warningMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Warning record) {
        record.setCreateTime(new Date());
        record.setDeleted(0);
        return warningMapper.insert(record);
    }

    @Override
    public int insertSelective(Warning record) {
        record.setCreateTime(new Date());
        return warningMapper.insertSelective(record);
    }

    @Override
    public Warning selectByPrimaryKey(Long id) {
        return warningMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Warning> selectAll() {
        return warningMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKeySelective(Warning record) {
        record.setCreateTime(new Date());
        return warningMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Warning record) {
        record.setCreateTime(new Date());
        return warningMapper.updateByPrimaryKey(record);
    }
}
